package com.ruoyi.daily.service.impl;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.daily.domain.dto.CustomerDto;
import com.ruoyi.daily.domain.dto.ReceivedThisMonthDto;
import com.ruoyi.daily.domain.dto.TodayOrderDto;
import com.ruoyi.daily.mapper.CollectingMonitorMapper;
import com.ruoyi.daily.service.CollectingMonitorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @Author cmz
 * @Date 2024-06-13 11:47
 */
@Service
public class CollectingMonitorServiceImpl implements CollectingMonitorService {
    @Resource
    private CollectingMonitorMapper collectingMonitorMapper;
    @Override
    public R<ReceivedThisMonthDto> receivedThisMonth() {
        ReceivedThisMonthDto receivedThisMonthDto = collectingMonitorMapper.receivedThisMonth();
        receivedThisMonthDto.setDailyTarget(5000.0);
        double v = receivedThisMonthDto.getDailyAverageReceipt() / receivedThisMonthDto.getDailyTarget()*100;
        DecimalFormat decimalFormat = new DecimalFormat("#.#");
        receivedThisMonthDto.setBusinessVolume(decimalFormat.format(v)+"%");
        return R.ok(receivedThisMonthDto);
    }

    @Override
    public R<TodayOrderDto> todayOrder() {
        TodayOrderDto todayOrderDto = collectingMonitorMapper.todayOrder();
        return R.ok(todayOrderDto);
    }

    @Override
    public R<List<CustomerDto>> customer() {
        List<CustomerDto> customerDto = collectingMonitorMapper.customer();
        return R.ok(customerDto);
    }
}
